<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    div{
         font-size: 20px;
    }
     .div1{
         background-color: coral;
         width: 200px;
         height: 200px;
     }
     .div2{
         background-color: bisque;
     }
</style>
<body>
    <div class="div1" name="这个人是帅哥">唐玮</div>
    <div class="div2" name="这个人是傻逼">曾少华</div>
</body>
<script>
    let map =new Map();
    // console.log( document.querySelectorAll("div"));//[div,div]
    document.querySelectorAll("div").forEach(item=>{
        map.set(item,{
            content :item.getAttribute("name")
        });
    });
    // console.log(map);
    map.forEach((key,value)=>{
      value.addEventListener("click",()=>{
          alert(key.content);
      })
    })
</script>
</html>